!macro preInit

		IfFileExists $LOCALAPPDATA\友空间\友空间.exe 0 done
  	;文件存在,退出程序并卸载旧版本
   	MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION  "检测到旧版本 ${PRODUCT_NAME} 。$\r$\n$\r$\n点击 “确定” 卸载旧版本${PRODUCT_NAME}。$\r$\n点击 “取消” 退出程序。" IDOK  actionOK  IDCANCEL Exit
   	;点击确认按钮
    actionOK:

    StrCpy $1 "友空间.exe"
    nsProcess::_FindProcess "$1"
    Pop $R0
    ${If} $R0 = 0 ;程序正在运行
    	nsProcess::_KillProcess "$1"
    	Pop $R0
    	Sleep 500
    ${EndIf}

		;卸载旧版本
    	ExecWait $LOCALAPPDATA\友空间\unins000.exe
    	Goto next
    Exit:
    	Quit
    next:
     Sleep 2000
    done:

!macroend

;若是安装权限不足，提升权限
!macro customInit
    ${if} $installMode == "all"
        ${IfNot} ${UAC_IsAdmin}
            ShowWindow $HWNDPARENT ${SW_HIDE}
            !insertmacro UAC_RunElevated
            Quit
        ${endif}
    ${endif}
!macroend


